<!-- 详情大页面 -->
<template>
  <div class="detail-container">
    <component v-if="isRouterAlive" :is="modelName" :parames="parames"></component>
  </div>
</template>

<script>
import FireSafetyAssess from './Model/FireSafetyAssess/Main' // 消防安全评估
import HighRiskSignal from './Model/HighRiskSignal/Main' // 高危信号
import ImportQuestion from './Model/ImportQuestion/Main' // 重大问题
import EquipmentList from './Model/EquipmentList/Main' // 设备清单
import HiddenDangers from './Model/HiddenDangers/Main' // 隐患整改
import MaintenanceTimeLine from './Model/Maintenance/Main' // 维保时间线
import PlatformManage from './Model/PlatformManage/Main' // 平台管理
import AICloudVideo from './Model/AICloudVideo/Main'

export default {
  name: 'Detail',
  props: {
    openDetail: {
      type: Function,
      default() {
        false
      }
    }
  },
  components: { 
    FireSafetyAssess,
    HighRiskSignal,
    ImportQuestion,
    EquipmentList,
    HiddenDangers,
    MaintenanceTimeLine,
    PlatformManage,
    AICloudVideo
  },
  data() {
    return {
      modelName: '', // 模块名称
      parames: {}, // 页面传递的参数,
      isRouterAlive: true
    }
  },
  created() {
    /*
     * 对外暴露先是详情页的方法
     */ 
    window.FunList.changeDetailModelShow = this.freshPage
    
  },
  methods: {
    /*
     * 初始化详情页的方法
     * 【参数说明】：
     *    isShow   控制详情页显示隐藏（默认是显示）
     *    pageName     详情页展示的模块名称
     *    parames  页面传递的参数
     *    callback 预留的回调方法
     */ 
    freshPage(isShow, pageName, parames, callback) {
      let that = this
      // 打开弹框
      if(that.openDetail && typeof(that.openDetail) === 'function') {
        that.openDetail(isShow || false)
      }

      if(/* that.$Ctl.isCs(true) && */ (that.modelName == pageName)){
        that.reload ()
      }
      that.modelName = pageName || ''
      that.parames = parames || {}
      // 如果是蜂鸟地图，在进入和离开全屏的详情页的时候，隐藏和显示FMap的canvas来节省内存
      let mapType = localStorage.getItem("ilinkBs_currentMapType")
      if(mapType == 2){
        isShow && $('.fmap-container').removeClass('is-show')
        !isShow && $('.fmap-container').addClass('is-show')
      }
    },
    reload () {
        this.isRouterAlive = false
        this.$nextTick(() => (this.isRouterAlive = true))
    }   
  },
}
</script>

<style lang="scss" scoped>
.detail-container {
  width: 100%;
  height: 100%;
  background-color: #061723;
}
</style>
